<?php

namespace App\Http\Controllers\Admin;

use App\Models\Config;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ConfigController extends Controller
{

    public function open()
    {
        $config = Config::first();
        return view('admin.system.update', compact('config'));
    }

    public function store(Request $request)
    {
        $data = $request->all();
        if ($config = Config::first()) {
            $config->fill($data);
        } else {
            $config = new Config($data);
        }
        $config->save();
        return redirect(route('admin.open'));
    }
}
